using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.ExceptionServices;
using Lockstep.Collision2D;
using Lockstep.Game;
using Lockstep.Math;
using Lockstep.Util;
using NetMsg.Common;
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Demos.RPGEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine;

namespace Lockstep.Game {
    [Serializable]
    public class EntityConfig {
        public int id;
        public LFloat moveSpd = 5;
        public LFloat turnSpd = 360;
        public int maxHealth = 100;
        public ColliderData colliderData;
        public AnimatorConfig animConfig;
        public SkillBoxConfig skillConfig;
        [AssetsOnly]
        public GameObject prefab;
    }


    [CreateAssetMenu(menuName = "ScriptableObject/GameConfig")]
    public class GameConfig : SerializedScriptableObject
    {
        public List<EntityConfig> entitys = new List<EntityConfig>();
        public List<AnimatorConfig> animators = new List<AnimatorConfig>();
        public List<SkillBoxConfig> skills = new List<SkillBoxConfig>();
        public List<MapConfig> maps = new List<MapConfig>();

        private Dictionary<int, EntityConfig> entityMap = new Dictionary<int, EntityConfig>();
        private Dictionary<int, MapConfig> mapMap = new Dictionary<int, MapConfig>();

        public void DoAwake(){
            foreach (var data in entitys)
            {
                entityMap[data.id] = data;
            }

            foreach (var data in maps) {
                mapMap[data.id] = data;
            }
        }

        public EntityConfig GetEntityConfig(int id){ return entityMap[id]; }


        public MapConfig GetMapConfig(int id) { 
            return mapMap[id];
        }
        public CollisionConfig CollisionConfig;
        public string RecorderFilePath;
        public string DumpStrPath;
        public Msg_G2C_GameStartInfo ClientModeInfo = new Msg_G2C_GameStartInfo();
    }
}